﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyForm.aspx.cs" Inherits="iSun.Web.Forms.MyForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" href="../dojo-release-1.7.2-src/dojo/resources/dojo.css"type="text/css" />
<link rel="stylesheet" href="../dojo-release-1.7.2-src/dijit/themes/claro/claro.css" />
<style>
 label
 {
     display:block; /*必须定这个样式属性，否则无法定宽度*/
     width:100px;
     font-weight:bold; 
     float:left;
 }
 
 #Master .ColSpan0
 {
     width:380px;
     float:left;
 }

#Master .cspan2
{
    width:565px;
    border-bottom:1px solid #eee
}

#Master .ColSpan1
{
     width:380px;
     float:left;
}
 
#Master .ColSpan2
{
     width:760px;
     float:left;
}
</style>
<script src="../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
<script src="../Scripts/Jquery.form.js" type="text/javascript"></script>
<script src="../Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
<script type="text/javascript">
    //定义常量
    var const_Entity = "";// eval("(<%=const_Entity%>)"), //实体对象
        const_SaveUrl = "../Extend/AjaxData/DataSave.aspx", //保存的页面数径
        const_EnttiyName = "<% =EntityName %>",//实体名
        const_KeyValue = "<% =KeyValue %>", //关键值
        const_Action = "<%=DataAction %>", //操作方法
        const_p = parent, //父页面
        const_MasterInstance = <%=JsMasterEntityInstance%>;
</script>
<script type="text/javascript">    dojoConfig = { parseOnLoad: true }</script>
<script type="text/javascript" src="../dojo-release-1.7.2-src/dojo/dojo.js"></script>
<script type="text/javascript">    require(["dojo/parser", "dijit/form/Form", "dijit/form/Button", "dijit/form/ComboBox", "dojo/store/Memory"]);</script>

<script type="text/javascript">
    var _dom, _on, _form;
    require([
    "dojo/ready", "dojo/dom", "dojo/store/Memory", "dijit/form/FilteringSelect", "dojo/on", "dojo/request", "dojo/dom-form"
, "dijit/dijit"], function (ready, dom, Memory, FilteringSelect, dom, on, request, domForm) {

    //此处用于生成字典所需的值！
    //    var dojoStore = new Memory({data: [
    //        {id: 1, name:"we", label:"<i>we</i> <img src='http://placekitten.com/50/70' />"},
    //        {id: 2, name:"are", label:"<u>are</u> <img src='http://placekitten.com/50/60' />"},
    //        {id: 3, name:"kittens", label:"<b>kittens</b> <img src='http://placekitten.com/50/50' />"}
    //    ]});
    onSave = function () {

        var url = "/Extend/AjaxData/DataSave.aspx?flag=1&entity=" + const_EnttiyName + "&action=" + const_Action;
        //        form.submit();
        var formOjbect = document.getElementById("postform");
        YAHOO.util.Connect.setForm(formOjbect);
        var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
    }


    var responseSuccess = function (res) {
        try {
            var str = res.responseText;

            if (str == "1") {
                alert("数据保存成功");
            }
            else {
                if (str != "") {

                    alert(str + "\n" + "数据保存失败!");
                }
            }
        }
        catch (e) {
        }
        finally {
        }
    };
    var responseFailure = function (error) {
        alert("数据错误：" + error.statusText);
    }

    // Create a callback object that defines success and failure
    // handlers, and instructs Connection Manager to use the
    // Flash transport by defining the xdr property and setting
    // it to true.
    var callback = {
        success: responseSuccess,
        failure: responseFailure
    };

    sendForm = function () {
        var form = dojo.byId("myForm");

        //alert(form.action);
        dojo.connect(form, "onsubmit", function (event) {
            // Stop the submit event since we want to control form submission.
            //dojo.stopEvent(event);

            // The parameters to pass to xhrPost, the form, how to handle it, and the callbacks.
            // Note that there isn't a url passed.  xhrPost will extract the url to call from the form's
            //'action' attribute.  You could also leave off the action attribute and set the url of the xhrPost object
            // either should work.
            var xhrArgs = {
                form: dojo.byId("myForm"),
                handleAs: "text",
                load: function (data) {
                    dojo.byId("response").innerHTML = "Form posted.";
                    alert("");
                },
                error: function (error) {
                    // We'll 404 in the demo, but that's okay.  We don't have a 'postIt' service on the
                    // docs server.
                    // dojo.byId("response").innerHTML = "Form posted.";
                    alert(error);
                }
            }

            // Call the asynchronous xhrPost
            //dojo.byId("response").innerHTML = "Form being sent..."
            var deferred = dojo.xhrPost(xhrArgs);
        });
    }

});






</script>
</head>
<body class="claro">
<div data-dojo-type="dijit/form/Form" id="myForm" data-dojo-id="myForm"
encType="multipart/form-data" action="" method="">
    <%=JsonData %>
    <div id="Master">
        <% =MasterHTML %>
    </div>
</div>
<form id="postform" style="display:none">
    <input id="Content" value=""/>
</form>
</body>
</html>

<%--
    Form
    http://dojotoolkit.org/reference-guide/1.8/dijit/index.html#dijit-index
     
     

     
    <script type="dojo/on" data-dojo-event="reset">
    alert(dojo.toJson($("#myForm").extractObject()));
    alert("test");
        return confirm('Press OK to reset widget values');
    </script>

    <script type="dojo/on" data-dojo-event="submit">
        alert(dojo.toJson(myForm.getValues()));
        if(this.validate()){
            return confirm('Form is valid, press OK to submit');
        }else{
            alert('Form contains invalid data.  Please correct first');
            return false;
        }
        return true;
    </script>
     
   
    <button data-dojo-type="dijit/form/Button" type="button" onClick="console.log(myForm.getValues())">Get Values from form!</button>
    <button data-dojo-type="dijit/form/Button" type="submit" name="submitButton" value="Submit">Submit</button>
    <button data-dojo-type="dijit/form/Button" type="reset">Reset</button>  
     --%>